package com.allwees.bs.c.module.address.spider;

import com.google.gson.Gson;
import retrofit2.Call;
import retrofit2.Response;
import retrofit2.Retrofit;
import retrofit2.converter.gson.GsonConverterFactory;
import retrofit2.http.GET;

import java.io.IOException;

public class FordealSpider implements ISpider {
    public interface AddressService {
        @GET("gw/dwp.trade-center-api.divisionFromId/1?data=%7B%22id%22%3A%2244027%22%7D&gw_ver=1&plat=pc&ct=1607086557013&appname=fordeal&sign=9ef835b6bb4d92631595f1aa9c5deb93")
        Call<Object> getProvince();
    }

    @Override
    public void work() {
        Retrofit retrofit = new Retrofit.Builder()
                .addConverterFactory(GsonConverterFactory.create(new Gson()))
                .baseUrl("https://gw.fordeal.com/")
                .build();

        AddressService addressService = retrofit.create(AddressService.class);
        Call<Object> jsonCall = addressService.getProvince();
        try {
            Response<Object> res = jsonCall.execute();
            System.out.println(res.body());
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
